package main.modelTests;

import main.model.persistence.ReadableObject;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Cardinalidad extends ReadableObject {

	private String atributo;

	private String minima;

	private String maxima;

	public void setAtributo(String atributo) {
		this.atributo = atributo;
	}

	public String getAtributo() {
		return atributo;
	}

	@Override
	public void loadObject(Node input) {
		NodeList childNodes = input.getChildNodes();
		for (int temp = 0; temp < childNodes.getLength(); temp++) {
			Node nNode = childNodes.item(temp);
			if (nNode.getNodeType() == Node.ELEMENT_NODE){
				NodeList subChilds = nNode.getChildNodes();
				Node subNode = subChilds.item(0);
				if (nNode.getNodeName().equals("atributo")){
					setAtributo(subNode.getNodeValue());
				}
				if (nNode.getNodeName().equals("minima")){
					setMinima(subNode.getNodeValue());
				}
				if (nNode.getNodeName().equals("maxima")){
					setMaxima(subNode.getNodeValue());
				}
			}
		}
	}

	public void setMinima(String minima) {
		this.minima = minima;
	}

	public String getMinima() {
		return minima;
	}

	public void setMaxima(String maxima) {
		this.maxima = maxima;
	}

	public String getMaxima() {
		return maxima;
	}

}
